/**
 * 
 */
package br.com.mb;

import java.util.Calendar;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import br.com.dao.impl.GenericDAO;
import br.com.model.Constante;
import br.com.model.Item;

/**
 * @author Joelson
 * 
 */
@SessionScoped
@ManagedBean
public class ItemBean {

	private Item item = new Item();

	List<Constante> listaConstante;

	public void gravar(Item item) {
		this.item = item;

		Calendar calendar = Calendar.getInstance();
		item.setData_inclusao(calendar.getTime());

		GenericDAO<Item> dao = new GenericDAO<Item>(Item.class);

		dao.adicionar(item);

	}

	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	public List<Constante> getListaConstante(Constante constante ) throws Exception {
		if (listaConstante == null) {

			listaConstante = new GenericDAO<Constante>(Constante.class).listaTodos();
		}
		return listaConstante;
	}

	public void setListaConstante(List<Constante> listaConstante) {
		this.listaConstante = listaConstante;
	}

}
